package com.hyq.learn.web.listenen;

import com.hyq.learn.web.env.LearnEnvironment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author heyuqin
 * @date 2024/5/27 17:54
 */
public class ApplicationFailedListener implements ApplicationListener<ApplicationFailedEvent> {
    private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationStartListener.class);

    private final LearnEnvironment learnEnvironment;

    public ApplicationFailedListener(LearnEnvironment learnEnvironment) {
        this.learnEnvironment = learnEnvironment;
    }
    @Override
    public void onApplicationEvent(ApplicationFailedEvent event) {
        LOGGER.error("项目启动失败");
        if (learnEnvironment.isDev()) {
            return;
        }
        System.out.println("prod failed....");
    }
}
